import Vue from 'vue';
import VueRouter, { RouteConfig } from 'vue-router';
import Home from '../views/Home.vue';

Vue.use(VueRouter);
/**
 * 关于meta属性
 * notTab: false|true 切换页面是否存放在tab -- default false
 * keepAlive: false|true, // 是否缓存页面 -- default false
 * name: '' 路由名称，显示在tab上 -- default ''
 * paramsName: '' 路由名称显示在tab上的备注 键 取params的值
 */

const routes: RouteConfig[] = [{
  path: '/not-found',
  meta: {
    notTab: true
  },
    component: () => import('@/views/OtherViews/NotFound.vue')
  },
  {
    path: '*',
    redirect: '/not-found'
  },
  {
    path: '/',
    name: 'Home',
    component: Home,
    meta: {
      name: '系统'
    },
    children: [
      {
        path: '/about',
        name: 'About',
        meta: {
          keepAlive: true,
          name: '关于'
        },
        component: () => import('@/views/TestPage/About.vue'),
      },
      {
        path: '/console',
        name: 'Console',
        meta: {
          keepAlive: true,
          name: '控制台'
        },
        component: () => import('@/views/OtherViews/Console.vue'),
      },
      {
        path: '/test',
        name: 'Test',
        meta: {
          keepAlive: false,
          name: '测试'
        },
        component: () => import('@/views/TestPage/Test.vue'),
      },
      {
        path: '/detail/:id',
        name: 'Detail',
        meta: {
          keepAlive: false,
          name: '详情',
          paramsName: 'id'
        },
        component: () => import('@/views/TestPage/Detail.vue')
      }
    ],
    redirect: '/console'
  }
];

const router = new VueRouter({
  mode: 'hash',
  base: process.env.BASE_URL,
  routes,
});

export default router;
